/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package lineage.config;

import lineage.config.L1Annotations.Configures;

/**
 * 服务器设置.
 * 
 * @version 2014年3月7日下午8:28:37
 * @author jrwz
 */
public final class L1Config {
    /** 服务器配置文件路径. */
    private static final String SERVER = "./config/server.properties";
    /** 数据库配置文件路径. */
    private static final String SQL = "./config/sql.properties";
    /** 角色配置文件路径. */
    private static final String CHAR = "./config/char.properties";

    private L1Config() {
    }

    // -------------------------------------------------------------------------
    // 游戏服务器相关 /** Server Settings */
    // -------------------------------------------------------------------------
    /** 服务器主机(IP). */
    @Configures(file = SERVER, key = "GameserverHostname")
    public static String GAME_SERVER_HOST_NAME = "*";
    /** 服务器端口. */
    @Configures(file = SERVER, key = "GameserverPort")
    public static int GAME_SERVER_PORT = 2000;
    /** 客户端语系. */
    @Configures(file = SERVER, key = "ClientLanguage")
    public static int CLIENT_LANGUAGE = 5;
    /** 客户端编码. */
    public static String CLIENT_LANGUAGE_CODE;
    /** 编码的清单. */
    private static String[] LANGUAGE_CODE_ARRAY = { "UTF8", "EUCKR", "UTF8", "BIG5", "SJIS", "GBK" };

    // -------------------------------------------------------------------------
    // 游戏数据库相关 /** SQL Settings */
    // -------------------------------------------------------------------------
    /** 数据库驱动程序. */
    @Configures(file = SQL, key = "Driver")
    public static String DB_DRIVER = "com.mysql.jdbc.Driver";
    /** 数据库路径. */
    @Configures(file = SQL, key = "URL")
    public static String DB_URL = "jdbc:mysql://localhost/lineage?useUnicode=true&characterEncoding=utf8";
    /** 数据库账号. */
    @Configures(file = SQL, key = "Login")
    public static String DB_LOGIN = "root";
    /** 数据库密码. */
    @Configures(file = SQL, key = "Password")
    public static String DB_PASSWORD = "root";

    // -------------------------------------------------------------------------
    // 角色相关 /** Char Settings */
    // -------------------------------------------------------------------------
    /** 角色数量上限(一个账号能创建的). */
    @Configures(file = CHAR, key = "charMaxCount")
    public static int CHAR_MAX_COUNT = 6;

    /**
     * 初始化.
     */
    public static void init() {
        new L1ConfigureLoader().load(L1Config.class);
        initClientLanguageCode();
    }

    /**
     * 初始化客户端编码.
     */
    private static void initClientLanguageCode() {
        CLIENT_LANGUAGE_CODE = LANGUAGE_CODE_ARRAY[CLIENT_LANGUAGE];
    }
}
